package queuedemo;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 黎鹤舞
 * Date: 2024-01-17
 * Time: 16:55
 */
class MyCircularQueue {

    private int[] elem;
    private int front;
    private int rear;
    private int size = 0;

    public MyCircularQueue(int k) {
        this.elem = new int[k];
        this.front = 0;
        this.rear = 0;
    }

    public boolean enQueue(int value) {
        return this.size == this.elem.length;
    }

    public boolean deQueue() {
        if(isEmpty()) {
            return false;
        }else {
            this.front++;
            this.size--;
            return true;
        }
    }

    public int Front() {
        if(isEmpty()) {
            return -1;
        }
        return this.elem[this.front];
    }

    public int Rear() {
        if(isEmpty()) { return -1; }
        return this.elem[this.rear];
    }

    public boolean isEmpty() {
        return this.size == 0;
    }

    public boolean isFull() {
        return this.size == this.elem.length;
    }
}

/**
 * Your MyCircularQueue object will be instantiated and called as such:
 * MyCircularQueue obj = new MyCircularQueue(k);
 * boolean param_1 = obj.enQueue(value);
 * boolean param_2 = obj.deQueue();
 * int param_3 = obj.Front();
 * int param_4 = obj.Rear();
 * boolean param_5 = obj.isEmpty();
 * boolean param_6 = obj.isFull();
 */
